package com.ibeeking.found.common.enums.mp;


/**
 * @Author ibeeking
 * @Date: 2021-01-05 19:15
 * @Description: 公共数据type enum
 */
public enum WxMpSourceTypeEnum {
    /**
     * 文本
     */
    TEXT(1,"TEXT"),

    /**
     * 图片
     */
    PIC(2,"PIC"),

    /**
     * 语音
     */
    VOICE(3,"VOICE"),

    /**
     * 视频
     */
    VIDEO(4,"VIDEO"),

    /**
     * 图文
     */
    IMAGE_TEXT(5,"IMAGE_TEXT"),

    /**
     * 音乐
     */
    MUSIC(6,"MUSIC"),

    /**
     * 缩略图
     */
    THUMB(7,"THUMB"),
    ;

    private Integer code;

    private String name;

    WxMpSourceTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }


    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
    public static String getNameByCode(Integer code) {
        for (WxMpSourceTypeEnum enumObj : values()) {
            if (enumObj.getCode().equals(code)) {
                return enumObj.getName();
            }
        }
        return null;
    }
    public static Integer getCodeByName(String name) {
        for (WxMpSourceTypeEnum enumObj : values()) {
            if (enumObj.getName().equals(name)) {
                return enumObj.getCode();
            }
        }
        return null;
    }

    public static WxMpSourceTypeEnum getEnum(Integer code) {
        for (WxMpSourceTypeEnum enumObj : values()) {
            if (enumObj.getCode().equals(code)) {
                return enumObj;
            }
        }
        return null;
    }
}